#include<stdio.h>

typedef struct date
{
	int year;
	int month;
	int day;
}DATE;
int main()
{
	DATE d;
	int sign,sum=0;
	scanf("%d,%d,%d",&d.year,&d.month,&d.day);
	for(sign=1;sign<d.month;sign++)
	{
		switch(sign)
		{
			case 1:
			case 3:
			case 5:
			case 7:
			case 8:
			case 10:
			case 12:sum+=31;break;
			case 2:if(d.year%4==0&&d.year%100!=0)
			{
				sum+=29;
			}
			else sum+=28;
			break;
			case 4:
			case 6:
			case 9:
			case 11:sum+=30;
			break;
		}
	}
	sum+=d.day;
	printf("%d",sum);
	return 0;
}
